#include "Comm.hpp"
#include <cstdio>

using namespace std;

int main()
{
    int fd = Open(FIFO_FILE, WRITER);
    
    key_t key = CreateKey();

    cout << "key: " << key << "\n";
    
    int shmid = shmget(key, MEM_SIZE, IPC_CREAT);

    if (shmid < 0)
    {
        return 2;
    }

    char *str = (char*)shmat(shmid, nullptr, 0);

    while(true)
    {
        printf("Please Enter# ");
        fflush(stdout);
        ssize_t s = read(0, str, MEM_SIZE);
        if (s > 0)
        {
            str[s] = '\0';
        }
        Signal(fd);
    }
}
